package com.b511.swpu.cementbackend.controller;

import com.b511.swpu.cementbackend.dto.input.BA_WellInputDto;
import com.b511.swpu.cementbackend.dto.input.WorkBaseInputDto;
import com.b511.swpu.cementbackend.dto.input.WorkQueryDto;
import com.b511.swpu.cementbackend.entity.BA_Well;
import com.b511.swpu.cementbackend.service.DataQueryService;
import com.b511.swpu.cementbackend.service.WorkBaseService;
import com.b511.swpu.cementbackend.util.R;
import io.swagger.annotations.Api;
import org.springframework.data.domain.PageRequest;
import org.springframework.web.bind.annotation.*;

import javax.print.attribute.standard.PrinterName;
import javax.servlet.http.HttpServletResponse;

@Api(value = "井口查询", tags = {"井口查询"})
@RestController
@RequestMapping("/workbase")
public class WorkBaseController {

    private final WorkBaseService workBaseService;

    public WorkBaseController(WorkBaseService workBaseService) {
        this.workBaseService = workBaseService;
    }

    //井口查询
    @GetMapping("/{num}/{size}")
    public R getWorkBaseByCondition(@PathVariable int num, @PathVariable int size, @ModelAttribute WorkBaseInputDto workBaseInputDto) throws Exception {
//        System.out.println(num);
        return workBaseService.getWorkByCondition(workBaseInputDto, PageRequest.of(num, size));
    }

    //查询country
    @GetMapping("/country")
    public R getCountries() throws Exception {
        return workBaseService.getCountry();
    }

    //查询作业单位
    @GetMapping("/company")
    public R getCompany() throws Exception {
        return workBaseService.getCompany();
    }

    //查询area
    @GetMapping("/area")
    public R getArea() throws Exception {
        return workBaseService.getArea();
    }

    //查询block-区块
    @GetMapping("/block")
    public R getBlock() throws Exception {
        return workBaseService.getBlock();
    }

    //查询OilField-油田
    @GetMapping("/oil_field")
    public R getOilField() throws Exception {
        return workBaseService.getOilField();
    }

    //查询wellType-井型
    @GetMapping("/well_type")
    public R getWellType() throws Exception {
        return workBaseService.getWellType();
    }

    //查询wellSpacing-井别
    @GetMapping("/well_spacing")
    public R getWellSpacing() throws Exception {
        return workBaseService.getWellSpacing();
    }

    //创建井眼
    @PostMapping("/buildWell")
    public R buildWell(@RequestBody BA_Well ba_well){
        System.out.println(ba_well);
        return workBaseService.buildWell(ba_well);
    }

    //删除井
    @DeleteMapping("/deleteWell/{wellName}")
    public R deleteWell(@PathVariable String wellName){
        return workBaseService.deleteWell(wellName);
    }

    //查询井信息
    @GetMapping("/getWell/{wellName}")
    public R getWell(@PathVariable String wellName){
        return workBaseService.getWell(wellName);
    }

    //编辑井信息
    @PutMapping("/putWell")
    public R putWell(@RequestBody BA_WellInputDto ba_WellInputDto){
        return workBaseService.putWell(ba_WellInputDto);
    }
}
